﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace WPFStudy.ViewModel
{
    /// <summary>
    /// VM基类，为了实现INotifyPropertyChanged
    /// </summary>
    public class MyViewModelBase : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler? PropertyChanged;

        ///// <summary>
        ///// 需要调用INotifyPropertyChanged.PropertyChanged时使用该方法
        ///// </summary>
        //public void OnPropertyChanged(string propertyName)
        //{
        //    PropertyChanged?.Invoke(this,new PropertyChangedEventArgs(propertyName));
        //}

        /// <summary>
        /// 需要调用INotifyPropertyChanged.PropertyChanged时使用该方法
        /// </summary>
        public void OnPropertyChanged([CallerMemberName] string propertyName = "")
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}
